using MinoChat.Ui.Enums;
using System.Windows;
using System.Windows.Controls;

namespace MinoChat.Ui.Controls;

/// <summary>
/// 卡片控件，左侧显示图标，中间显示标题内容，右侧显示自定义内容
/// </summary>
public class CardControl : ContentControl
{
    static CardControl()
    {
        DefaultStyleKeyProperty.OverrideMetadata(typeof(CardControl),
            new FrameworkPropertyMetadata(typeof(CardControl)));
    }

    #region 依赖属性

    /// <summary>
    /// 左侧图标（IconType 枚举）
    /// </summary>
    public static readonly DependencyProperty IconProperty =
        DependencyProperty.Register(
            nameof(Icon),
            typeof(IconType),
            typeof(CardControl),
            new PropertyMetadata(IconType.None));

    public IconType Icon
    {
        get => (IconType)GetValue(IconProperty);
        set => SetValue(IconProperty, value);
    }

    /// <summary>
    /// 中间标题内容（通常是标题和说明）
    /// </summary>
    public static readonly DependencyProperty HeaderProperty =
        DependencyProperty.Register(
            nameof(Header),
            typeof(object),
            typeof(CardControl),
            new PropertyMetadata(null));

    public object Header
    {
        get => GetValue(HeaderProperty);
        set => SetValue(HeaderProperty, value);
    }

    /// <summary>
    /// 卡片圆角半径
    /// </summary>
    public static readonly DependencyProperty CornerRadiusProperty =
        DependencyProperty.Register(
            nameof(CornerRadius),
            typeof(CornerRadius),
            typeof(CardControl),
            new PropertyMetadata(new CornerRadius(8)));

    public CornerRadius CornerRadius
    {
        get => (CornerRadius)GetValue(CornerRadiusProperty);
        set => SetValue(CornerRadiusProperty, value);
    }

    /// <summary>
    /// 鼠标悬停时的背景色
    /// </summary>
    public static readonly DependencyProperty HoverBackgroundProperty =
        DependencyProperty.Register(
            nameof(HoverBackground),
            typeof(System.Windows.Media.Brush),
            typeof(CardControl),
            new PropertyMetadata(null));

    public System.Windows.Media.Brush HoverBackground
    {
        get => (System.Windows.Media.Brush)GetValue(HoverBackgroundProperty);
        set => SetValue(HoverBackgroundProperty, value);
    }

    /// <summary>
    /// 鼠标悬停时的边框色
    /// </summary>
    public static readonly DependencyProperty HoverBorderBrushProperty =
        DependencyProperty.Register(
            nameof(HoverBorderBrush),
            typeof(System.Windows.Media.Brush),
            typeof(CardControl),
            new PropertyMetadata(null));

    public System.Windows.Media.Brush HoverBorderBrush
    {
        get => (System.Windows.Media.Brush)GetValue(HoverBorderBrushProperty);
        set => SetValue(HoverBorderBrushProperty, value);
    }

    #endregion
}
